package com.example.cyw.sqlhelper;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    private ListView listView;
    private ArrayList<Comcont> mlist;
    private MyAdapter adapter;
    private Button btn_add;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btn_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MainActivity.this,ComcontActivity.class);
                startActivity(intent);
            }
        });

    }

    private void initView() {
        listView=findViewById(R.id.listview);
        btn_add=findViewById(R.id.btn_add);
        mlist=new ArrayList<>();
        mlist.add(new Comcont("大家好，我是渣渣辉"));
        mlist.add(new Comcont("是兄弟,就来砍我"));
        adapter=new MyAdapter(MainActivity.this,mlist);
        listView.setAdapter(adapter);
    }
}
